from ui.components.base.widget import TgBaseWidget
from ui.components.layouts.vbox_layout import TgVBoxLayout
from ui.components.containers.tab_widget import TgTabWidget
from .basis_monitor_tab import BasisMonitorTab
from .placeholder_tab import PlaceholderTab


class StockIndexWidget(TgBaseWidget):
    def __init__(self):
        super().__init__()

        # 创建 Tab 控件
        self.tabs = TgTabWidget()
        self.basis_monitor_tab = BasisMonitorTab()
        self.futures_options_tab = PlaceholderTab()
        self.favorites_tab = PlaceholderTab()
        self.holdings_tab = PlaceholderTab()

        self.tabs.addTab(self.basis_monitor_tab, "基差监控")
        self.tabs.addTab(self.futures_options_tab, "股指期权")
        self.tabs.addTab(self.favorites_tab, "自选")
        self.tabs.addTab(self.holdings_tab, "持仓")


        TgVBoxLayout(self).addWidget(self.tabs)
    
    
    def cleanup(self):
        """清理资源"""
        if hasattr(self, 'basis_monitor_tab'):
            self.basis_monitor_tab.cleanup()